package com.qms.tubu.adapter;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.qms.tubu.fragment.CycleFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Mad on 2015/7/2.
 */
public class CycleFragmentAdapter extends FragmentStatePagerAdapter{
    private List<String> urlList;
    public CycleFragmentAdapter(FragmentManager fm) {
        super(fm);
        urlList=new ArrayList<String>();
        urlList.add("http://qianmosen.cn/tubu/Public/Upload/otherScenic/76fa38a4a03be77920f208f18a4195f11.jpg");
        urlList.add("http://qianmosen.cn/tubu/Public/Upload/otherScenic/76fa38a4a03be77920f208f18a4195f12.jpg");
        urlList.add("http://qianmosen.cn/tubu/Public/Upload/otherScenic/76fa38a4a03be77920f208f18a4195f13.jpg");
    }

    @Override
    public Fragment getItem(int position) {
        position=position%urlList.size();
        CycleFragment fragment=new CycleFragment();
        Bundle bundle=new Bundle();
        bundle.putString("scenic",urlList.get(position));
        fragment.setArguments(bundle);
        return fragment;
    }
    public List<String> getList()
    {
        return urlList;
    }
    @Override
    public int getCount() {
        if(urlList.size()<2)
            return urlList.size();
        else
            return Integer.MAX_VALUE;
    }
}
